package com.archetypus.projectschedule.web.activities.cmd;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.archetypus.projectschedule.common.dto.activities.Activity;
import com.archetypus.projectschedule.common.dto.activities.ActivityKey;
import com.archetypus.projectschedule.common.exceptions.ProjectSchedulerException;
import com.archetypus.projectschedule.web.activities.bd.ActivityBD;
import com.archetypus.projectschedule.web.activities.bd.IActivityBD;
import com.archetypus.projectschedule.web.common.cmd.ICommand;

public class FindActivityCmd implements ICommand {

	public void execute(HttpServletRequest request, HttpServletResponse response)throws ProjectSchedulerException {
		int activityId = Integer.parseInt(request.getParameter("activity"));
		
		ActivityKey activityKey = new ActivityKey();
		activityKey.setId(activityId);
		
		Activity activity = new Activity();
		activity.setActivityKey(activityKey);
		
		IActivityBD activityBD = new ActivityBD();
		Activity selectedActivity = activityBD.findActivity(activity);
		
		request.setAttribute("activity", selectedActivity);
	}

}
